#this application backup important files
import os
import time

#1. the filesand directory to be backed up are specified in a list. #
source = ['C:\\DOCS', 'C:\\Users\HAYWHY\Downloads\Python']

#2. The backup must be stored in a main backup directory #
target_dir = 'E:\\MY_python_Backup'

#3. The backup will be saved in a zip file.#
#4. The currrent time will be the name.of the subdirectory in the main directory.#
today = target_dir + os.sep + time.strftime('%Y%m%d')

#the current time is the name of the subdirectory
now = time.strftime('%H%M%S')

#now create the subdirectory if it's not there already
if not os.path.exists(today):
    os.mkdir(today) # create the directory
    print('successfully created file directory', today)

#the name of the file
target = today + os.sep + now + '.zip'

#we use the zip command to put the files in a zip achive
zip_command = "zip -r {0} {1}".format(target, ' '.join(source))

#run the backup
if os.system(zip_command) == 0:
    print('Successful backup to target', target)
else:
    print('Backup Unsuccessful')
